package com.buddies.lottery.ui.lottery.history;

import android.content.Context;
import android.content.Intent;

import com.buddies.lottery.base.list.BaseListActivity;
import com.buddies.lottery.data.bean.Lottery;
import com.buddies.lottery.data.bean.LotteryReward;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.HashMap;
import java.util.Map;

public class LotteryHistoryActivity extends BaseListActivity<LotteryReward, LotteryHistoryContract.Presenter> implements LotteryHistoryContract.View {

    private Lottery mLottery;

    @Override
    protected String getHeaderTitle() {
        return "开奖结果";
    }

    @Override
    protected void initData() {
        Intent intent = getIntent();
        if (intent != null) {
            mLottery = (Lottery) intent.getSerializableExtra("lottery");
        }

        super.initData();

        mPresenter = new LotteryHistoryPresenter(this);
    }

    @Override
    protected BaseQuickAdapter createAdapter() {
        return new LotteryHistoryAdapter(null);
    }

    @Override
    public void onLoadData(int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("lotteryId", mLottery.id);

        ((LotteryHistoryContract.Presenter) mPresenter).onLoadData(params, page);
    }

    public static void launch(Context context, Lottery lottery) {
        Intent intent = new Intent(context, LotteryHistoryActivity.class);
        intent.putExtra("lottery", lottery);
        context.startActivity(intent);
    }

}
